<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>

<html>

<head>
	<%
    	UserService userService = UserServiceFactory.getUserService();
    	User user = userService.getCurrentUser();
	%>
	<title>Login</title>
    <link rel="stylesheet" href="customThemeJ/themes/StudyStatTheme1.min.css" />
	<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile.structure-1.0rc2.min.css" />	
	<script src="http://code.jquery.com/jquery-1.7.1.js"></script> 
	<script src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
    
    <script type="text/javascript">
	function idsubmit() 
	{
		var form = document.getElementById("loginID");
		form.submit();
	}
	</script>

</head>
  
<body>
<div data-role="page" data-theme="b">
	<!-- Titelbalk -->
	<div data-role="header" data-position="inline" data-theme="b">
	<a href="" data-icon="star" class="ui-btn-left" rel="external">Achievements</a>
	<h1>The Real Study Stat</h1>
	<a href="" data-icon="gear" class="ui-btn-right">Options</a>
	<div data-role="navbar">
		<ul>
			<li><a href="" rel="external">Home</a></li>
			<li><a href="" rel="external">Statistieken</a></li>
			<li><a href="contact.html" rel="external">Contact</a></li>
			<li><a href="about.html" rel="external">Over Ons</a></li>
			<li><a href="<%= userService.createLogoutURL("/login") %>" rel="external">Uitloggen</a></li>
		</ul>
	</div>
	</div>
	
	<div data-role="content">
	<!-- Loginscherm -->
	<% if (user != null) { %>
		<div id="content">
	
			Hallo, <%= user.getNickname() %>!

			<form id="loginID" action="/login" method="post" data-ajax="false">
				<input type="hidden" name="userID" value= "<%= user.getUserId() %>"/>
			</form>
	
			<script type="text/javascript">
			var t;
			t = setTimeout("idsubmit()", 1500);
			</script>
		</div>
	<%
   		} else {
   	%>		
   		<div id="content">
			<p><a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Log in om verder te gaan</a></p>
		</div>
	<%
    	}
	%>
	
  </div>
  </div>
  </body>
</html>